package com.zhulei.biji.juc;

import java.util.concurrent.Exchanger;

/**
 * @description:
 * @author: zhulei
 * @create: 2025-04-25 15:21
 **/
public class ExchengeTest {
    private static final Exchanger<String> exchanger = new Exchanger<>();

    public static void main(String[] args) throws InterruptedException {
       Thread t1 =  new Thread(() -> {
           System.out.println("线程 1 收到的数据：b");
        });
        t1.start();

        Thread t2 = new Thread(() -> {
            System.out.println("线程 1 收到的数据：a");
        });
        t2.start();

        while (true){
            t1.wait();
            t1.notify();
            t2.wait();
            t2.notify();
        }
    }
}
